#include "aboutdialog.h"
#include "ui_aboutdialog.h"

AboutDialog::AboutDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AboutDialog),
    oldMPt(0, 0),
    isPressed(false)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint|Qt::Tool|Qt::WindowStaysOnTopHint);
    this->setAttribute(Qt::WA_TranslucentBackground);
    QObject::connect(ui->btnClose, SIGNAL(clicked()), this, SLOT(close()));
    this->setFocus();
}

void AboutDialog::mousePressEvent(QMouseEvent* event){
    if(event->button() == Qt::LeftButton && !isPressed){
        isPressed = true;
        oldMPt = event->globalPos() - this->pos();
        this->setCursor(Qt::ClosedHandCursor);
    }
}

void AboutDialog::mouseMoveEvent(QMouseEvent* event){
    if(isPressed){
        this->move(event->globalPos() - oldMPt);
        event->accept();
    }
}

void AboutDialog::mouseReleaseEvent(QMouseEvent* event){
    if(event->button() == Qt::LeftButton && isPressed){
        isPressed = false;
        this->setCursor(Qt::ArrowCursor);
        event->accept();
    }
}

AboutDialog::~AboutDialog()
{
    delete ui;
}
